package com.abai.doubi.entity;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class Result<T> {
    public String code;
    public String msg;
    public T data;

    public static String SUCCESS_CODE = "10000";
    public static String ERROR_CODE = "99999";
    public static String UNAUTHORIZED_CODE = "40001";
    public static Result error(){
        return Result.builder().code(ERROR_CODE).build();
    }
    public static Result error(String msg){
        return Result.builder().code(ERROR_CODE).msg(msg).build();
    }

    public static Result success(){
        return Result.builder().code(SUCCESS_CODE).build();
    }
    public static Result success(String msg){
        return Result.builder().code(SUCCESS_CODE).msg(msg).build();
    }

    public static Result unauthorized(){
        return Result.builder().code(UNAUTHORIZED_CODE).build();
    }

    public static Result unauthorized(String msg){
        return Result.builder().code(UNAUTHORIZED_CODE).msg(msg).build();
    }
}
